package com.cloud.dao;

import com.cloud.controller.ProjectController;
import com.cloud.dto.ProjectDto;
import com.cloud.entity.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface ProjectRepository extends JpaRepository<Project,Integer>{

    @Query(value = "select project.* from project,team,user where user.user_id=?1 and team.team_id=user.team_id and team.p_id=project.p_id", nativeQuery = true)
    public Project findProjectByPId(Integer user_id);

    @Query(value = "select * from project where p_title=?1", nativeQuery = true)
    public List<Project> findProjectByPTitle(String p_title);

    @Query(value = "select * from project",nativeQuery = true)
    List<Project> allProjects();

//    @Query(value = "insert into project(p_title,task,s_t,tnumber,tsum,leader_id,e_t,desct,comp_tasknum," +
//            "p_time,tasknum,leader_name) values(:#{#project.p_title},:#{#project.task}," +
//            ":#{#project.s_t},:#{#project.tnumber},:#{#project.tsum},:#{#project.leader_id}," +
//            ":#{#project.e_t},:#{#project.desct},:#{#project.comp_tasknum},:#{#project.p_time}," +
//            ":#{#project.tasknum},:#{#project.leader_name})",nativeQuery = true)
//    Boolean AddProject(@Param("project") Project project);




}
